/*
	   _           _      _           _     _ 
	  (_)         | |    | |         (_)   | |
	   _ _   _ ___| |_ __| |_ __ ___  _  __| |
	  | | | | / __| __/ _` | '__/ _ \| |/ _` |
	  | | |_| \__ \ || (_| | | | (_) | | (_| |
	  | |\__,_|___/\__\__,_|_|  \___/|_|\__,_|
	 _/ |                                     
	|__/ 
	
	Copyright 2013 Caspar Isemer and and Eva Krueger, http://justdroid.org
	
	Licensed under the Apache License, Version 2.0 (the "License");
	you may not use this file except in compliance with the License.
	You may obtain a copy of the License at
	
		http://www.apache.org/licenses/LICENSE-2.0
	
	Unless required by applicable law or agreed to in writing, software
	distributed under the License is distributed on an "AS IS" BASIS,
	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	See the License for the specific language governing permissions and
	limitations under the License. 
*/

package org.justdroid.justdroid;

import java.util.ArrayList;
import java.util.HashMap;

import android.content.Context;
import android.content.Intent;
import android.graphics.Typeface;
import android.net.Uri;
import android.os.Bundle;
import android.os.Vibrator;
import android.text.Html;
import android.view.GestureDetector;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.view.View.OnKeyListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

public class ContactsDetailsMenu extends JustDroidActivity {
	
	/** Declare variables and UI elements **/
	private TextView btnContactName;
	private Button btnEditContactName;
	private String number;
	private String contactId;
	private HashMap<String, ArrayList<String>> contactDetails;
	@SuppressWarnings("unused")
	private GestureDetector gestureDetector;
	
	void editNumber(String id, String num, String numType) {
		Intent intent = new Intent(getApplicationContext(), ContactUpdate.class);
	    intent.putExtra("id", id);
	    intent.putExtra("number", num);
	    intent.putExtra("numtype", numType);
	    startActivity(intent);
	    finish();
	}
	
	void editMail(String id, String email) {
		Intent intent = new Intent(getApplicationContext(), ContactUpdate.class);
	    intent.putExtra("id", id);
    	intent.putExtra("mail", email);
	    startActivity(intent);
	    finish();
	}
	
	void attachKeyListener(final Button button, final int buttonFlag, final String num, final String numType, final String email) {
		button.setOnKeyListener(new OnKeyListener() {
			
			@Override
			public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
				if(keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
					switch(keyCode) {
					case KeyEvent.KEYCODE_SPACE:
						switch(buttonFlag) {
							case 1:
								onSpaceEvent(button,  ContactsDetailsMenu.this.contactId, button.getText().toString(), null, null, null);
								break;
							case 2:
								onSpaceEvent(button, ContactsDetailsMenu.this.contactId, button.getText().toString(), num, numType, null);
								break;
							case 3:
								onSpaceEvent(button, ContactsDetailsMenu.this.contactId, button.getText().toString(), num, numType, null);
								break;
							case 4:
								onSpaceEvent(button, ContactsDetailsMenu.this.contactId, button.getText().toString(), null, null, email);
								break;
						}
						break;
					}
				}
				return false;
			}
		});
	}
	
	void onSpaceEvent(Button btn, String id, String name, String number, String numType, String email) {
		int flag;
		final int NUMBER = 1;
		final int EMAIL = 2;
		final int NAME = 3;
		if(btn.getText().toString().toLowerCase().startsWith(getResources().getString(R.string.call)) || btn.getText().toString().toLowerCase().startsWith(getResources().getString(R.string.sendmessage))) {
			//button corresponds to a number
			flag = NUMBER;
		}
		else if(btn.getText().toString().toLowerCase().startsWith(getResources().getString(R.string.mail))) {
			//button corresponds to an email id
			flag = EMAIL;
		}
		else {
			//button corresponds to the name
			flag = NAME;
		}
		 Intent intent = new Intent(getApplicationContext(), ContactUpdate.class);
	    intent.putExtra("id", ContactsDetailsMenu.this.contactDetails.get("id").get(0));
	    if(flag == NAME) {
	    	intent.putExtra("name", ContactsDetailsMenu.this.contactDetails.get("name").get(0));
	    	intent.putExtra("details", ContactsDetailsMenu.this.contactDetails);
	    }
	    else if(flag == NUMBER) {
	    	intent.putExtra("number", number);
	    	intent.putExtra("numtype", numType);
	    }
	    else if(flag == EMAIL) {
	    	intent.putExtra("mail", email);
	    }
	    
	    startActivity(intent);
	    finish();
	}
	
	void callOtherOptions() {
		Intent intent = new Intent(getApplicationContext(), ContactsOtherOptions.class);
		intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		intent.putExtra("id", ContactsDetailsMenu.this.contactId);
		intent.putExtra("number", ContactsDetailsMenu.this.number);
		startActivity(intent);
		finish();
	}
	
	void callDialer(View view) {
		//pass number to dialer app
		Intent intent = new Intent(getApplicationContext(), PhoneDialerApp.class);
		intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		int positionOfNewLine = (((Button)view).getText().toString()).indexOf("\n");
		intent.putExtra("call", (((Button)view).getText().toString().substring(positionOfNewLine)).trim());
		startActivity(intent);
		finish();
	}
	
	void callMessagesApp(View view) {
		//pass number to dialer app
		Intent intent = new Intent(getApplicationContext(), TextMessagesComposerApp.class);
		intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		int positionOfNewLine = (((Button)view).getText().toString()).indexOf("\n");
		intent.putExtra("number", (((Button)view).getText().toString().substring(positionOfNewLine)).trim());
		startActivity(intent);
		finish();
	}
	
	/** Function to dial a phone number on button click **/
	void dialNumberOnButtonClick(int buttonInt, final String strDialNumber) {
		Button button = (Button) findViewById(buttonInt);
		button.setOnClickListener(new View.OnClickListener() {
	        public void onClick(View v) {
	        	if(strDialNumber != null && !strDialNumber.isEmpty()) {
	        		Uri number = Uri.parse("tel:" + strDialNumber);
	        		Intent dial = new Intent(Intent.ACTION_CALL, number);
	        		startActivity(dial);
	        		finish();
	        	}
	        }
	    });
	} 	
	
	/** Function to announce the text of the view that received focus or on which the onTouch event was triggered**/
	void giveFeedback(String text) {
		//vibrate
		Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
	    vibrator.vibrate(300);
	    //TTS feedback
	    TTS.speak(text);
	}
	
	/** Create the Contact Details menu activity **/
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		setContentView(R.layout.contactsdetails);
		super.onCreate(savedInstanceState);
		
		/** get UI elements **/
		btnContactName = (TextView) findViewById(R.id.txtContactsName);
		btnEditContactName = (Button) findViewById(R.id.btnEditContactName);
		
		//attachKeyListener(btnContactName, 1, null, null, null);
		/*btnContactName.setOnTouchListener(new OnTouchListener() {
            GestureDetector gestureDetector = new GestureDetector(getApplicationContext(), new ButtonGestureListener(btnContactName, ContactsDetailsMenu.this.contactId, btnContactName.getText().toString(), null, null, null));
            @Override
        	public boolean onTouch(View v, MotionEvent event) {
               return gestureDetector.onTouchEvent(event);
        	}
		});*/
		
		
		/** get the details of the contact from the number **/
		this.number = getIntent().getExtras().getString("number");
		this.contactId = getIntent().getExtras().getString("id");
		this.contactDetails = new ContactManager(getApplicationContext()).getDetailsFromNumber(this.contactId);
		btnContactName.setText(this.contactDetails.get("name").get(0));
		btnEditContactName.setText("Edit " + this.contactDetails.get("name").get(0));
		
		for(int i=0; i<contactDetails.get("numbers").size(); i++) {
			
			final String num = contactDetails.get("numbers").get(i);
			final String numType = contactDetails.get("types").get(i);
			final Button btnCall = new Button(getApplicationContext());
			final Button btnEditNumber = new Button(getApplicationContext());
			btnCall.setText("Call " + numType + Html.fromHtml("<br/>" + num));
			btnCall.setContentDescription("Call " + numType + " " + num);
			btnCall.setTextColor(getResources().getColor(R.drawable.card_textcolor));
			btnCall.setTypeface(Typeface.DEFAULT_BOLD);
			btnCall.setTextSize(getResources().getDimension(R.dimen.card_textsize_regular));
			btnCall.setGravity(Gravity.CENTER);
			btnCall.setFocusable(true);
			btnEditNumber.setText("Edit " + numType + Html.fromHtml("<br/>" + num));
			btnEditNumber.setContentDescription("Edit " + btnContactName.getText().toString() + " " + numType + " " + num);
			btnEditNumber.setTextColor(getResources().getColor(R.drawable.card_textcolor));
			btnEditNumber.setTypeface(Typeface.DEFAULT_BOLD);
			btnEditNumber.setTextSize(getResources().getDimension(R.dimen.card_textsize_regular));
			btnEditNumber.setGravity(Gravity.CENTER);
			btnEditNumber.setFocusable(true);
			LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
			btnCall.setLayoutParams(params);
			btnEditNumber.setLayoutParams(params);
			LinearLayout layout = (LinearLayout)findViewById(R.id.linearLayout);
			layout.addView(btnCall);
			layout.addView(btnEditNumber);
			
			//attachKeyListener(btnCall, 2, num, numType, null);
			//attachKeyListener(btnEditNumber, 2, num, numType, null);
			
			/*btnCall.setOnTouchListener(new OnTouchListener() {
	             GestureDetector gestureDetector = new GestureDetector(getApplicationContext(), new ButtonGestureListener(btnCall, ContactsDetailsMenu.this.contactId, btnContactName.getText().toString(), num, numType, null));
	             @Override
	         	public boolean onTouch(View v, MotionEvent event) {
	                return gestureDetector.onTouchEvent(event);
	         	}
			});*/
			
			btnCall.setOnFocusChangeListener(new OnFocusChangeListener() {
				
				@Override
				public void onFocusChange(View view, boolean hasFocus) {
					if(hasFocus) {
						giveFeedback(((Button)view).getText().toString());
					}
				}
			});
			
			btnCall.setOnClickListener(new OnClickListener() {
				
				@Override
				public void onClick(View view) {
					callDialer(view);
				}
			});
			
			btnCall.setOnKeyListener(new OnKeyListener() {
				
				@Override
				public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
					if(keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
						switch(keyCode) {
						case KeyEvent.KEYCODE_DPAD_CENTER:
						case KeyEvent.KEYCODE_ENTER:
							callDialer(view);
							break;
						}
					}
					return false;
				}
			});
			
			/** Button to send SMS **/
			final Button btnSms = new Button(getApplicationContext());
			btnSms.setText("Send Message to " + numType + Html.fromHtml("<br/>" + num));
			btnSms.setContentDescription("Send Message to " + numType + " " + num);
			//btnCall.setBackground(getResources().getDrawable(R.drawable.card));
			btnSms.setTextColor(getResources().getColor(R.drawable.card_textcolor));
			btnSms.setTypeface(Typeface.DEFAULT_BOLD);
			btnSms.setTextSize(getResources().getDimension(R.dimen.card_textsize_regular));
			btnSms.setGravity(Gravity.CENTER);
			btnSms.setFocusable(true);
			params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
			//params.weight = 1.0f;
			btnCall.setLayoutParams(params);
			layout = (LinearLayout)findViewById(R.id.linearLayout);
			layout.addView(btnSms);
			
			//attachKeyListener(btnSms, 2, num, numType, null);
			
			/*btnSms.setOnTouchListener(new OnTouchListener() {
				GestureDetector gestureDetector = new GestureDetector(getApplicationContext(), new ButtonGestureListener(btnSms, ContactsDetailsMenu.this.contactId, btnContactName.getText().toString(), num, numType, null));
	            @Override
	         	public boolean onTouch(View v, MotionEvent event) {
	                return gestureDetector.onTouchEvent(event);
	         	}
			});*/
			
			btnSms.setOnFocusChangeListener(new OnFocusChangeListener() {
				
				@Override
				public void onFocusChange(View view, boolean hasFocus) {
					if(hasFocus) {
						giveFeedback(((Button)view).getText().toString());
					}
				}
			});
			
			btnSms.setOnClickListener(new OnClickListener() {
				
				@Override
				public void onClick(View view) {
					callMessagesApp(view);
				}
			});
			
			btnSms.setOnKeyListener(new OnKeyListener() {
				
				@Override
				public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
					if(keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
						switch(keyCode) {
						case KeyEvent.KEYCODE_DPAD_CENTER:
						case KeyEvent.KEYCODE_ENTER:
							callMessagesApp(view);
							break;
						}
					}
					return false;
				}
			});
			
			btnEditNumber.setOnFocusChangeListener(new OnFocusChangeListener() {
				
				@Override
				public void onFocusChange(View view, boolean hasFocus) {
					if(hasFocus) {
						giveFeedback(((Button)view).getText().toString());
					}
				}
			});
			
			btnEditNumber.setOnClickListener(new OnClickListener() {
				
				@Override
				public void onClick(View view) {
					editNumber(ContactsDetailsMenu.this.contactDetails.get("id").get(0), num, numType);					
				}
			});
			
			btnEditNumber.setOnKeyListener(new OnKeyListener() {
				
				@Override
				public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
					if(keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
						switch(keyCode) {
						case KeyEvent.KEYCODE_DPAD_CENTER:
						case KeyEvent.KEYCODE_ENTER:
							editNumber(ContactsDetailsMenu.this.contactDetails.get("id").get(0), num, numType);
							break;
						}
					}
					return false;
				}
			});			
		}
		
		
		//display emails
		for(int i=0; i<contactDetails.get("emails").size(); i++) {
			final String email = contactDetails.get("emails").get(i);
			final Button btnEmail = new Button(getApplicationContext());
			final Button btnEditEmail = new Button(getApplicationContext());
			
			btnEmail.setText("Email " + Html.fromHtml("<br/>" + email));
			btnEmail.setContentDescription("Email " + email);
			btnEmail.setTextColor(getResources().getColor(R.drawable.card_textcolor));
			btnEmail.setTypeface(Typeface.DEFAULT_BOLD);
			btnEmail.setTextSize(getResources().getDimension(R.dimen.card_textsize_regular));
			btnEmail.setGravity(Gravity.CENTER);
			btnEmail.setFocusable(true);
			btnEditEmail.setText("Edit " + Html.fromHtml("<br/>" + email));
			btnEditEmail.setContentDescription("Edit " + email);
			btnEditEmail.setTextColor(getResources().getColor(R.drawable.card_textcolor));
			btnEditEmail.setTypeface(Typeface.DEFAULT_BOLD);
			btnEditEmail.setTextSize(getResources().getDimension(R.dimen.card_textsize_regular));
			btnEditEmail.setGravity(Gravity.CENTER);
			btnEditEmail.setFocusable(true);
			LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
			btnEmail.setLayoutParams(params);
			btnEditEmail.setLayoutParams(params);
			LinearLayout layout = (LinearLayout)findViewById(R.id.linearLayout);
			layout.addView(btnEmail);
			layout.addView(btnEditEmail);
			
			//attachKeyListener(btnEmail, 3, null, null, email);
			
			/*btnEmail.setOnTouchListener(new OnTouchListener() {
				GestureDetector gestureDetector = new GestureDetector(getApplicationContext(), new ButtonGestureListener(btnEmail, ContactsDetailsMenu.this.contactId, btnContactName.getText().toString(), null, null, email));
	            @Override
	         	public boolean onTouch(View v, MotionEvent event) {
	                return gestureDetector.onTouchEvent(event);
	         	}
			});*/
			
			btnEmail.setOnFocusChangeListener(new OnFocusChangeListener() {
				
				@Override
				public void onFocusChange(View view, boolean hasFocus) {
					if(hasFocus) {
						giveFeedback(((Button)view).getText().toString());
					}
				}
			});
			
			btnEditEmail.setOnClickListener(new OnClickListener() {
				
				@Override
				public void onClick(View view) {
					editMail(ContactsDetailsMenu.this.contactId, email);
				}
			});
		}
		
		//more options
		final Button btnMoreOptions = new Button(getApplicationContext());
		
		btnMoreOptions.setText("More Options");
		btnMoreOptions.setContentDescription("More Options");
		btnMoreOptions.setTextColor(getResources().getColor(R.drawable.card_textcolor));
		btnMoreOptions.setTypeface(Typeface.DEFAULT_BOLD);
		btnMoreOptions.setTextSize(getResources().getDimension(R.dimen.card_textsize_regular));
		btnMoreOptions.setGravity(Gravity.CENTER);
		btnMoreOptions.setFocusable(true);
		LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
		btnMoreOptions.setLayoutParams(params);
		LinearLayout layout = (LinearLayout)findViewById(R.id.linearLayout);
		layout.addView(btnMoreOptions);
		
		btnContactName.setOnFocusChangeListener(new OnFocusChangeListener() {
			
			@Override
			public void onFocusChange(View view, boolean hasFocus) {
				if(hasFocus) {
					giveFeedback(((Button)view).getText().toString());
				}
			}
		});
		
		btnEditContactName.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View view) {
				Intent intent = new Intent(getApplicationContext(), ContactUpdate.class);
			    intent.putExtra("id", ContactsDetailsMenu.this.contactDetails.get("id").get(0));
			    intent.putExtra("name", ContactsDetailsMenu.this.contactDetails.get("name").get(0));
			    intent.putExtra("details", ContactsDetailsMenu.this.contactDetails);
			    startActivity(intent);
			    finish();
			}
		});
		
		btnEditContactName.setOnKeyListener(new OnKeyListener() {
			
			@Override
			public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
				if(keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
					switch(keyCode) {
					case KeyEvent.KEYCODE_DPAD_CENTER:
					case KeyEvent.KEYCODE_ENTER:
						Intent intent = new Intent(getApplicationContext(), ContactUpdate.class);
					    intent.putExtra("id", ContactsDetailsMenu.this.contactDetails.get("id").get(0));
					    intent.putExtra("name", ContactsDetailsMenu.this.contactDetails.get("name").get(0));
					    intent.putExtra("details", ContactsDetailsMenu.this.contactDetails);
					    startActivity(intent);
					    finish();
						break;
					}
				}
				return false;
			}
		});
		
	/*	btnContactName.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View view) {
				callOtherOptions(view);
			}
		});*/
		
		/*btnContactName.setOnKeyListener(new OnKeyListener() {
			
			@Override
			public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
				if(keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
					switch(keyCode) {
					case KeyEvent.KEYCODE_DPAD_CENTER:
					case KeyEvent.KEYCODE_ENTER:
						callOtherOptions(view);
						break;
					}
				}
				return false;
			}
		});*/
		
		btnEditContactName.setOnFocusChangeListener(new OnFocusChangeListener() {
			
			@Override
			public void onFocusChange(View view, boolean hasFocus) {
				if(hasFocus) {
					giveFeedback(((Button)view).getText().toString());
				}
			}
		});

		btnMoreOptions.setOnFocusChangeListener(new OnFocusChangeListener() {
			
			@Override
			public void onFocusChange(View view, boolean hasFocus) {
				if(hasFocus) {
					giveFeedback(((Button)view).getText().toString());
				}
			}
		});
		
		btnMoreOptions.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View view) {
				callOtherOptions();
			}
		});
		
		btnMoreOptions.setOnKeyListener(new OnKeyListener() {
			
			@Override
			public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
				if(keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
					switch(keyCode) {
					case KeyEvent.KEYCODE_DPAD_CENTER:
					case KeyEvent.KEYCODE_ENTER:
						callOtherOptions();
						break;
					}
				}
				return false;
			}
		});

		// The OnClick code below for btnContactsNumber1, btnContactsNumber1, btnContactsNumber1
		// is just dummy code; it should actually receive all the numbers from the contact selected
		// via ContactsApp.java, display all numbers each as a separate button and upon clicking
		// calls the selected number	
		
		/** Dial respective phone number, depending on which button is pressed **/
		//dialNumberOnButtonClick(R.id.btnContactsNumber1, "+491771111111");
		//dialNumberOnButtonClick(R.id.btnContactsNumber2, "+49401111111");
		//dialNumberOnButtonClick(R.id.btnContactsNumber3, "+4940808171111");
				
		/** Put most everything before here **/
	}	

	@Override
	public void onStop() {
		
		super.onStop();
		if(TTS.isSpeaking()) {
			TTS.stop();
		}
	}
	
	public class ButtonGestureListener extends GestureDetector.SimpleOnGestureListener {
		public Context context;
		public String phno, id, contactName, contactNumber, numtype, email;
		private Button button;
		private int flag;
		final int NUMBER = 1;
		final int EMAIL = 2;
		final int NAME = 3;
		
		public ButtonGestureListener(Button btn, String id, String name, String number, String numType, String email) {
			this.button = btn;
			if(this.button.getText().toString().toLowerCase().startsWith(getResources().getString(R.string.call)) || btn.getText().toString().toLowerCase().startsWith(getResources().getString(R.string.sendmessage))) {
				//button corresponds to a number
				this.flag = NUMBER;
			}
			else if(this.button.getText().toString().toLowerCase().startsWith(getResources().getString(R.string.mail))) {
				//button corresponds to an email id
				this.flag = EMAIL;
			}
			else {
				//button corresponds to the name
				this.flag = NAME;
			}
			this.id = id;
			this.contactName = name;
			this.contactNumber = number;
			this.numtype = numType;
			this.email = email;
		}
		
		@Override
		public boolean onDown(MotionEvent e) {
		    
			return super.onDown(e);
		}
		
		@Override
		public boolean onDoubleTap(MotionEvent e) {
		    Intent intent = new Intent(getApplicationContext(), ContactUpdate.class);
		    intent.putExtra("id", ContactsDetailsMenu.this.contactDetails.get("id").get(0));
		    if(this.flag == NAME) {
		    	intent.putExtra("name", ContactsDetailsMenu.this.contactDetails.get("name").get(0));
		    	intent.putExtra("details", ContactsDetailsMenu.this.contactDetails);
		    }
		    else if(this.flag == NUMBER) {
		    	intent.putExtra("number", this.contactNumber);
		    	intent.putExtra("numtype", this.numtype);
		    }
		    else if(this.flag == EMAIL) {
		    	intent.putExtra("mail", this.email);
		    }
		    
		    startActivity(intent);
		    finish();
		    return true;
		}
		
		@Override
		public boolean onSingleTapUp(MotionEvent e) {
		//	giveFeedback(this.button.getText().toString());
		    return super.onSingleTapUp(e);
		}
	}
	
	@Override
	public void onResume() {
		super.onResume();
		//get the root layout
		LinearLayout layout = (LinearLayout) findViewById(R.id.contactsdetails);
		Utils.applyFontColorChanges(getApplicationContext(), layout);  Utils.applyFontSizeChanges(getApplicationContext(), layout);  Utils.applyFontTypeChanges(getApplicationContext(), layout);
	}
}
